package com.esri.core.tasks.ags.geoprocessing;

import com.esri.core.geometry.SpatialReference;
import com.esri.core.internal.util.d;
import com.esri.core.io.EsriServiceException;
import com.esri.core.map.Graphic;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;
import org.codehaus.jackson.map.MappingJsonFactory;

/* loaded from: classes.dex */
public class GPRecordSet extends GPParameter {
    private static final String EXCEEDED_TRANSFER_LIMIT = "exceededTransferLimit";
    private static final long serialVersionUID = 1;
    private boolean exceededTransferLimit;
    private ArrayList<Graphic> graphics;

    public ArrayList<Graphic> getGraphics() {
        return this.graphics;
    }

    public void setGraphics(ArrayList<Graphic> arrayList) {
        this.graphics = arrayList;
    }

    public void addGraphic(Graphic graphic) {
        if (this.graphics == null) {
            this.graphics = new ArrayList<>();
        }
        this.graphics.add(graphic);
    }

    public GPRecordSet(String str) {
        this.graphics = new ArrayList<>();
        setParamName(str);
        this.dataType = "GPRecordSet";
    }

    public GPRecordSet() {
        this("");
    }

    @Override // com.esri.core.tasks.ags.geoprocessing.GPParameter
    public Map<String, String> generateRequestParams() {
        HashMap hashMap = (HashMap) super.generateRequestParams();
        hashMap.put(EXCEEDED_TRANSFER_LIMIT, String.valueOf(this.exceededTransferLimit));
        return hashMap;
    }

    @Override // com.esri.core.tasks.ags.geoprocessing.GPParameter
    public String generateValueParams() throws Exception {
        StringWriter stringWriter = new StringWriter();
        JsonGenerator createJsonGenerator = new MappingJsonFactory().createJsonGenerator(stringWriter);
        createJsonGenerator.writeStartObject();
        if (this.graphics != null) {
            createJsonGenerator.writeFieldName("features");
            createJsonGenerator.writeStartArray();
            Iterator<Graphic> it = this.graphics.iterator();
            while (it.hasNext()) {
                createJsonGenerator.writeRawValue(d.a(it.next(), (SpatialReference) null));
            }
            createJsonGenerator.writeEndArray();
        }
        createJsonGenerator.writeEndObject();
        createJsonGenerator.close();
        return stringWriter.getBuffer().toString();
    }

    @Override // com.esri.core.tasks.ags.geoprocessing.GPParameter
    public void fromJson(JsonParser jsonParser) throws Exception {
        if (!d.c(jsonParser)) {
            throw new EsriServiceException("Unable to parse the Response for this GPRecordSet.");
        }
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if ("features".equals(currentName)) {
                while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                    this.graphics.add(d.j(jsonParser));
                }
            } else if (EXCEEDED_TRANSFER_LIMIT.equals(currentName)) {
                this.exceededTransferLimit = jsonParser.getBooleanValue();
            } else {
                jsonParser.skipChildren();
            }
        }
    }

    public int hashCode() {
        int i = ((this.exceededTransferLimit ? 1231 : 1237) + 31) * 31;
        ArrayList<Graphic> arrayList = this.graphics;
        return i + (arrayList == null ? 0 : arrayList.hashCode());
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            GPRecordSet gPRecordSet = (GPRecordSet) obj;
            if (this.exceededTransferLimit != gPRecordSet.exceededTransferLimit) {
                return false;
            }
            ArrayList<Graphic> arrayList = this.graphics;
            if (arrayList == null) {
                if (gPRecordSet.graphics != null) {
                    return false;
                }
            } else if (arrayList.size() != gPRecordSet.graphics.size() || !this.graphics.containsAll(gPRecordSet.graphics)) {
                return false;
            }
            return true;
        }
        return false;
    }
}
